<?php

class XA_Benchmark {

	protected $timestamps = array();
	
	public function start($description = null) {
		$id = count($this->timestamps);
		$this->timestamps[$id]['description'] = $description;
		$this->timestamps[$id]['time'] = $this->microtime();
		return $id;
	}
	
	protected function microtime() {
		list($usec, $sec) = explode(" ", microtime());
		return ((float)$usec + (float)$sec);
	}
	
	public function getTime($id) {
		return ($this->microtime() - $this->timestamps[$id]['time'])*1000;
	}
}
